
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:osc/res/colors.dart';
import 'package:osc/res/dimens.dart';

class PdTextField extends StatefulWidget {
  final Widget icon;
  final String hintText;
  final bool obscureText;
  final EdgeInsetsGeometry margin;
  final TextEditingController controller;
  final TextInputType textInputType;
  final List<TextInputFormatter> inputFormatters;
  final FocusNode focusNode;

  const PdTextField({Key key, this.icon, this.hintText, this.obscureText, this.margin, this.controller, this.textInputType, this.inputFormatters, this.focusNode}) : super(key: key);

  @override
  _PdTextFieldState createState() => new _PdTextFieldState();
}

class _PdTextFieldState extends State<PdTextField> {

  @override
  Widget build(BuildContext context) {
    return new Theme(
        data: ThemeData(
            primaryIconTheme: IconThemeData(color: Colors.blue)
        ),
        child: Container(
          decoration: BoxDecoration(
              color: Colours.gray_ef,
              borderRadius: BorderRadius.circular(5)
          ),
          padding: EdgeInsets.only(left: Dimens.gap_view_big),
//      margin: EdgeInsets.only(top: Dimens.gap_view_big),
          margin: widget.margin,
          child: TextField(
            obscureText: widget.obscureText == null?false:true,
            keyboardType: widget.textInputType,
            inputFormatters: widget.inputFormatters,
            decoration: InputDecoration(
              icon: widget.icon,
              hintText: widget.hintText,
              hintStyle: TextStyle(
                  color: Colours.gray_99
              ),
              border: InputBorder.none,
            ),
            controller: widget.controller,
            onChanged: (s){

            },
            focusNode: widget.focusNode,
          ),
        )
    );
  }
}
